package day16;


import java.io.*;
import java.util.Arrays;
import java.util.HashSet;

/**
 * @author ZJX
 * @version 1.0
 * @descption
 * @since 2025/10/27 14:47
 */
public class Week02 {
    /*
    https://www.nowcoder.com/practice/bd891093881d4ddf9e56e7cc8416562d?tpId=182&tqId=34785&ru=/exam/oj
    字符串中连续最长的数字串
     */
//    public static void main(String[] args) throws IOException {
//        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//        PrintWriter out = new PrintWriter(System.out);
//        String s = in.readLine().trim(); // 读取字符串
//        int maxLen = 0;
//        String maxStr = "";
//        StringBuilder curStr = new StringBuilder();
//        for (char ch : s.toCharArray()){
//            if (Character.isDigit(ch)){
//                curStr.append(ch);
//            } else {
//                if (curStr.length() > maxLen){
//                    maxLen = curStr.length();
//                    maxStr = curStr.toString();
//                }
//                curStr.setLength(0);
//            }
//        }
//        if (curStr.length() > maxLen){
//            maxStr = curStr.toString();
//        }
//        out.println(maxStr);
//        out.close();
//    }


    //    给出6根棍子，能否在选出3根拼成一个三角形的同时剩下的3根也能组成一个三角形？
//    public static void main(String[] args) throws IOException {
//        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//        PrintWriter out = new PrintWriter(System.out);
//        // 正确读取测试用例数量 t：先获取标记，再取值
//        in.nextToken(); // 移动到第一个标记（t的值）
//        int t = (int) in.nval; // 取出t的值
//        int[] arr = new int[6];
//        while (t-- > 0) {
//            for (int i = 0; i < 6; i++) {
//                in.nextToken();
//                arr[i] = (int) in.nval;
//            }
//            Arrays.sort(arr);
//            boolean valid = (arr[0] + arr[1] > arr[2] && arr[3] + arr[4] > arr[5])
//                    || (arr[0] + arr[2] > arr[3] && arr[1] + arr[4] > arr[5])
//                    || (arr[0] + arr[3] > arr[4] && arr[1] + arr[2] > arr[5])
//                    || (arr[0] + arr[4] > arr[5] && arr[1] + arr[2] > arr[3]);
//            out.println(valid ? "Yes" : "No");
//        }
//        out.close();
//    }

    public int compareVersion(String version1, String version2) {
        String[] v1 = version1.split("\\.");
        String[] v2 = version2.split("\\.");
        int len = Math.max(v1.length, v2.length);
        for (int i = 0; i < len; i++) {
            int m = i < v1.length ? Integer.parseInt(v1[i]) : 0;
            int n = i < v2.length ? Integer.parseInt(v2[i]) : 0;
            if (m > n) {
                return 1;
            }
            if (m < n) {
                return -1;
            }
        }
        return 0;
    }

    //    最长连续序列
    public int longestConsecutive(int[] nums) {
        if (nums.length == 0 || nums.length == 1) {
            return nums.length;
        }
        HashSet<Integer> set = new HashSet<>();
        for (int n : nums) {
            set.add(n);
        }
        int ret = 1;
        for (int x : set) {
//            如果不存在 x-1 说明x是起点
            if (!set.contains(x - 1)) {
                int curNum = x;
                int curLen = 1;
                while (set.contains(curNum + 1)) {
                    curLen++;
                    curNum++;
                }
                ret = Math.max(ret, curLen);
            }
        }
        return ret;
    }
//    https://www.nowcoder.com/practice/9740ce2df0a04399a5ade1927d34c1e1?tpId=230&tqId=38954&ru=/exam/oj


    public boolean checkDynasty(int[] places) {
        Arrays.sort(places);
        int zero = 0;
        for (int i = 0; i < 5; i++) {
            if (places[i] == 0) {
                zero++;
                continue;
            }
            if (i > 0 && places[i] == places[i - 1]) {
                return false;
            }
        }
        if (zero == 5) {
            return true;
        }
        return places[4] - places[zero] < 5;
    }

//    public static void main(String[] args) throws IOException {
//        // 添加逗号
//        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        PrintWriter out = new PrintWriter(System.out);
//
//        String s = br.readLine().trim();
//        StringBuilder sb = new StringBuilder(s);
//        sb.reverse();
//        for (int i = 3; i < sb.length(); i += 4) {
//            sb.insert(i, ",");
//        }
//        out.println(sb.reverse().toString());
//        out.close();
//    }

    // https://leetcode.cn/problems/longest-palindromic-substring/
    public String longestPalindrome(String s) {
//           中心扩散法
        // (right - 1) - (left + 1) + 1 = right - left - 1
        if (s == null || s.isEmpty()) {
            return "";
        }
        int begin = 0, len = 0, n = s.length();
//        奇数扩散
        for (int i = 0; i < n; i++) {
            int left = i, right = i;
            while (left >= 0 && right < n && s.charAt(left) == s.charAt(right)) {
                left--;
                right++;
            }
            if (right - left - 1 > len) {
                begin = left + 1;
                len = right - left - 1;
            }
        }
        for (int i = 0; i < n; i++) {
            int left = i, right = i + 1;
            while (left >= 0 && right < n && s.charAt(left) == s.charAt(right)) {
                left--;
                right++;
            }
            if (right - left - 1 > len) {
                begin = left + 1;
                len = right - left - 1;
            }
        }
        return s.substring(begin, begin + len);
    }

//    public static void main(String[] args) throws IOException {
//        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//        PrintWriter out = new PrintWriter(System.out);
//        in.nextToken();
//        int n = (int) in.nval;
//        int[] nums = new int[n];
//        for (int i = 0; i < n; i++) {
//            in.nextToken();
//            nums[i] = (int) in.nval;
//        }
//        int profit = 0;
//        int min = 100000;
//        for (int i = 0; i < n; i++) {
//            profit = Math.max(profit, nums[i] - min);
//            min = Math.min(min, nums[i]);
//        }
//        out.println(profit);
//        out.close();
//    }

//    public static void main(String[] args) throws IOException {
//        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//        PrintWriter out = new PrintWriter(System.out);
//        in.nextToken();
//        int n = (int) in.nval;
//
//        while (n-- > 0) {
//            in.nextToken();
//            int y = (int) in.nval;
//            in.nextToken();
//            int o = (int) in.nval;
//            in.nextToken();
//            int u = (int) in.nval;
//
//            int youCount = Math.min(y, Math.min(o, u));
//            int remainingO = o - youCount;
//            int ooScore = Math.max(0, remainingO - 1);
//            out.println(youCount * 2 + ooScore);
//        }
//        out.close();
//    }

//    public static void main(String[] args) throws IOException {
//        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        PrintWriter out = new PrintWriter(System.out);
//        String[] s = br.readLine().split(" ");
//        StringBuilder sb = new StringBuilder();
//        for (int i = s.length - 1; i >= 0; i--) {
//            if (i == 0) {
//                sb.append(s[i]);
//            } else {
//                sb.append(s[i]).append(" ");
//            }
//        }
//        out.println(sb);
//        out.close();
//    }

    public static void main(String[] args) throws IOException {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(System.out);
        in.nextToken();
        int n = (int) in.nval;
        in.nextToken();
        int m = (int) in.nval;
        in.nextToken();
        int x = (int) in.nval;
        in.nextToken();
        int y = (int) in.nval;
        int[][] dp = new int[n + 1][m + 1]; // dp[i][j] 表示有效路径条数

    }

    private boolean isForbidden(int n, int m, int x, int y, int point1, int point2) {
        if (point1 < 0 || point1 > n || point2 < 0 || point2 > m) {
            return false;
        }
        if (n == x && y == m) {
            return true;
        }
        int dx = Math.abs(x - n);
        int dy = Math.abs(y - m);

        return (dx + dy == 3) && (dx != 0) && (dy != 0);
    }

    public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
        if (pHead1 == null || pHead2 == null) {
            return null;
        }
        ListNode cur1 = pHead1;
        ListNode cur2 = pHead2;
        int len1 = 0;
        int len2 = 0;
        while (cur1 != null) {
            len1++;
            cur1 = cur1.next;
        }
        while (cur2 != null) {
            len2++;
            cur2 = cur2.next;
        }
        cur1 = pHead1;
        cur2 = pHead2;
        int diff = Math.abs(len2 - len1);
        if (len2 > len1) {
            for (int i = 0; i < diff; i++) {
                cur2 = cur2.next;
            }
        } else if (len1 > len2) {
            for (int i = 0; i < diff; i++) {
                cur1 = cur1.next;
            }
        }
        while (cur1 != cur2) {
            cur1 = cur1.next;
            cur2 = cur2.next;
        }
        return cur2;
    }

    class ListNode {
        int val;
        ListNode next = null;

        ListNode(int val) {
            this.val = val;
        }
    }
}



